$(function () {
    $("#page").load("/html/page.html");
    // searchAll();
});
function searchAll() {
    let data = {
        name: $("#name").val(),
        sex: $("#sex").find("option:selected").text(),
        pageSize: $.trim($("#pageSize").val()),
        pageNum: $.trim($("#pageNum").val()),
    }
    console.log(data);
    let result = myAjax('/teacher/selectClassTeacher', "post", data)
    show(result.list);
    $("#pageCount").html(result.number);
}

function show(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += '   <tr> ' +
            '  <td><input type="checkbox" name="isCheck" value="'+data[i].id+'">' + data[i].id + '</td>\n' +
            '        <td>' + data[i].name + '</td>\n' +
            '        <td>' + data[i].sex + '</td>\n' +
            '        <td><input type="button" style="width: 60px;border-radius: 5px" value="删除" onclick="del(' + data[i].id + ')"></td>' +
            '    </tr>';
    }
    $("#findAll").html(html);
}
function del(id) {
    let result = myAjax("/teacher/deleteClassTeacher", "get", {id: id})
    if (result === 1) {
        alert("删除成功");
        searchAll();
    }
}